﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;

namespace Evaluant.NLinq.Memory
{
    public class Variant
    {
        protected Dictionary<string, object> members = new Dictionary<string, object>();

        public object this[string propertyName]
        {
            get { return members[propertyName]; }
            set { members[propertyName] = value; }
        }

        public string[] PropertyNames
        {
            get
            {
                var propertyNames = new string[members.Keys.Count];
                members.Keys.CopyTo(propertyNames, 0);
                return propertyNames;
            }
        }

        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("{ ");
            foreach (KeyValuePair<string, object> entry in members)
            {
                sb.Append(entry.Key).Append(" = ").Append(entry.Value.ToString()).Append("; ");
            }
            sb.Append(" }");

            return sb.ToString();
        }
    }
}
